import {defHttp} from '/@/utils/http/axios';
import { BasicPageSearchParams } from "/@/api/model/baseModel";
import {AreaInfo, AreaParams,} from "./model/areaModel";


enum Api {
  list = '/SysArea/list',
  view = '/SysArea/view/',
  getChildren = '/SysArea/getChildren/',
}

export const list = (params?: any) => {
  const query = params && { pageNum: params.pageNum, pageSize: params.pageSize };
  let entity = params || {};
  if (entity) {
    delete entity['pageNum'];
    delete entity['pageSize'];
  }
  const queryParam = { query, entity } as BasicPageSearchParams<any>;
  return defHttp.post<any>({ url: Api.list, params: queryParam });
};

export const view = (id?: number) => {
  return defHttp.get<any>({ url: Api.view + id });
};

export const getChildren = (id?: number) => {
  return defHttp.get<AreaInfo>({url: Api.getChildren + id});
};


